package com.njxxted.activiti.modules.process.extend.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.njxxted.activiti.common.util.PageUtil;
import com.njxxted.activiti.common.util.StringUtils;
import com.njxxted.activiti.modules.process.extend.dao.ExtendActOpinionDao;
import com.njxxted.activiti.modules.process.extend.entity.ActOpinionEntity;
import com.njxxted.activiti.modules.process.extend.service.ExtendActOpinionService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.Objects;

/**
 * 描述：流程审批常用意见表 service
 * <p>
 * 作者：HuTongFu
 * 邮箱：hu_tongfu@163.com
 * 时间：2019-08-07 09:34:07
 */
@Service("actOpinionService")
public class ExtendActOpinionServiceImpl implements ExtendActOpinionService {

    @Resource
    private ExtendActOpinionDao extendActOpinionDao;

    @Override
    public ActOpinionEntity queryObject(String id) {
        return extendActOpinionDao.queryObject(id);
    }

    @Override
    public PageUtil<ActOpinionEntity> queryList(ActOpinionEntity param) {
        if (Objects.isNull(param)) {
            return null;
        }
        PageHelper.startPage(param.getPageNum(), param.getPageSize());
        List<ActOpinionEntity> actOpinionEntityList = extendActOpinionDao.queryList(param);
        PageInfo<ActOpinionEntity> pageInfo = new PageInfo<>(actOpinionEntityList);
        return new PageUtil<>(actOpinionEntityList, (int) pageInfo.getTotal(), pageInfo.getPageSize(), pageInfo.getPageNum());

    }

    @Override
    public List<ActOpinionEntity> queryListByBean(ActOpinionEntity param) {
        return extendActOpinionDao.queryListByBean(param);
    }

    @Override
    public int save(ActOpinionEntity actOpinionEntity) {
        actOpinionEntity.setId(StringUtils.uuidGenerator());
        return extendActOpinionDao.save(actOpinionEntity);
    }

    @Override
    public int update(ActOpinionEntity actOpinionEntity) {
        return extendActOpinionDao.update(actOpinionEntity);
    }

    @Override
    public int delete(String id) {
        return extendActOpinionDao.delete(id);
    }

    @Override
    public int deleteBatch(String[] ids) {
        return extendActOpinionDao.deleteBatch(ids);
    }

}
